home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Systemmonitors
/
PickPacket
/
PickPack.Doc
< prev
next >
Wrap
Text File
|
1996-09-26
|
12KB
|
208 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* |_o_o|\\ Copyright © 1989 The Software Distillery. *
* |. o.| || All Rights Reserved. *
* | . | || Written by John Toebes and Doug Walker *
* | o | || The Software Distillery *
* | . |// 235 Trillingham Lane *
* ====== Cary, NC 27513 *
* BBS:(919)-471-6436 *
* BIX: JTOEBES, DWALKER *
* PLINK: JTOEBES, DWALKER *
* Usenet: ...mcnc!rti!sas!(toebes|walker) *
* CI$: sorry, charlie... *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
------------------------------COPYRIGHT NOTICE
PickPacket is Copyright © 1989 The Software Distillery. See the file
README.PP for distribution information.
------------------------------DISCLAIMER
Neither The Software Distillery nor any of its members will be liable for
any damage arising from the failure of this program to perform as described,
or any destruction of other programs or data residing on a system
attempting to run the program. While we expect no damaging errors, the
user of this program uses it at his or her own risk.
--------------------------------------------------------------------------
PICKPACKET - EXPLORING THE PACKET INTERFACE TO AMIGADOS
(The concepts discussed here are covered in much greater detail in an
article in 'Transactor for the Amiga', May 1989 issue.)
We first had the idea to write this program while working on a file system
for AmigaDOS. It turned out that we were writing lots of tiny little C
programs that sent a particular packet to our file system. Once we had
decided to write it, however, we saw that it would be a useful tool for
new programmers to explore the packet interface to DOS. We hope you will
enjoy it!
AmigaDOS handlers and file systems communicate with application programs
via Messages and MsgPorts, just like most other Amiga system-level tasks do.
There is a handler or file system in charge of every device you have on
your Amiga, from df0: and ram: to ser: and par:. When you call a function
in dos.library such as Open() or Lock(), dos.library determines which
handler to call and sends it the appropriate packet to do the requested
action. If this explanation doesn't make sense to you, try reading the
description of the packet interface in Amiga Transactor, May 1989, or in
the AmigaDOS Technical Reference Manual (part of the AmigaDOS manual by
Bantam Books).
PickPacket gives a visual display of the DosPacket structure that is sent
to the handlers and lets you see the results. You can actually open files,
read and write data, Examine() and ExNext() locks, and so forth, all by
talking directly to the file system involved from PickPacket.
------------------------------GETTING STARTED
To run PickPacket, either double-click on its icon or type "PickPacket"
from the CLI. From the CLI, you can optionally specify an initial device,
as in "PickPacket RAM:". The default initial device is df0:, but you can
select a different one once inside the program.
------------------------------THE PICKPACKET WINDOW
The PickPacket window has many interesting little gadgets and areas.
The dp_Type field contains the packet type of the packet you are working on.
You can select new packet types from the menus, or you can cycle through
the list of packet types by clicking on the left or the right of the data
field for dp_Type.
Below the dp_Type field are four lines for dp_Arg1, dp_Arg2, dp_Arg3 and
dp_Arg4. These four fields correspond to the four possible arguments that
you can pass to a file system. They contain different values depending on
what packet type you have selected. A short description of the type of
argument required in that field for that packet type is listed on the
right of the data field. The box on the right of each dp_Arg field is
a string gadget that contains the value of that field at the moment. The
box on the left (with the name "dp_Arg?" in it) is a boolean gadget. You
can use the dp_Arg gadgets to enter values into the string gadgets, as
will be described below.
Below the four dp_Arg fields are two dp_Res fields. These fields will show
the results of the packet you have sent. Most packets return DOSTRUE in
dp_Res1 to indicate success and DOSFALSE in dp_Res1 to indicate failure.
If the packet failed, dp_Res2 contains the error code indicating why. If
it succeeded, dp_Res2 SHOULD BE IGNORED. Some handlers fill it in with
an error code EVEN IF THE PACKET SUCCEEDS. Exceptions to the DOSTRUE/
DOSFALSE rule are the ACTION_READ and ACTION_WRITE packets, which return
the number of bytes read or written if successful and -1 for an error.
In the upper left-hand corner is a gadget labeled "Device". If you started
PickPacket from the CLI and specified a device, that device name will be
in the string gadget; otherwise, it will say "df0:". The device listed
is the one that will receive your packets. To change it, click on the
device name and type in a new one.
Immediately to the right of the device gadget is the "Send Packet" gadget.
When you click here, PickPacket transmits your packet to the device.
PickPacket does some validation of the arguments in the dp_Arg fields, but
it is VERY easy to crash your system by sending invalid or nonsense data
to a handler!!!!
The four gadgets to the right of the "Send Packet" gadget allocate various
data structures you will need to do some of the more interesting packets.
"Allocate HANDLE" allocates a FileHandle structure; you will need a
FileHandle structure to open files for read or write. "Allocate INFODATA"
allocates a struct InfoData, which is used to get information about a disk
or volume mounted on a handler. "Allocate FILEINFO" is used to allocate
a FileInfoBlock, which is passed to get information about a file or
directory. "Allocate BUFFER" is used to allocate a data buffer to read
into or write from. Any time you allocate a data structure, a new window
representing that data structure will pop up. One additional window that
may pop up is the Lock window; when you do a Lock, the file system
allocates the lock structure on your behalf. Therefore, the only way to
get a Lock window is to send an ACTION_LOCATE_OBJECT packet to a handler.
------------------------------KNOWING THE PLAYERS
The descriptions to the right of the dp_Arg fields can ask for several
different types of objects. A short description of each follows. You
may need to look at a more detailed reference guide (Transactor or the
AmigaDOS manual) to determine what arguments are actually needed.
FileLock - A FileLock is a structure allocated on your behalf when you
pass an ACTION_LOCATE_OBJECT to the handler. NULL is a valid
Lock, however, and it indicates the root of the file system.
The first ACTION_LOCATE_OBJECT you do, therefore, will pass in
a NULL lock and the full pathname of the object to lock. You
can specify a NULL lock by selecting NULL from the "Constants"
menu, then clicking on the appropriate dp_Arg button on the
left side of the screen.
STRING - A STRING usually means the packet wants a filename. If a
FileLock is also asked for in the same packet, the Lock should
be a lock on a directory, and the STRING should be a filename
relative to that directory. For example, if you have a Lock
on df0:c, you could Lock df0:c/dir by sending the lock on
df0:c and a relative pathname of "dir". One exception to the
filename rule is in an ACTION_SET_COMMENT packet, where the
second STRING asked for is the comment desired.
Integer - An Integer field is to contain some kind of integer constant.
When doing Reads and Writes, an Integer indicates how many
bytes to read or write; when Locking or Opening files, it
contains a constant from the "Constants" menu. In particular,
the ACTION_LOCATE_OBJECT packet wants a constant SHARED_LOCK
or EXCLUSIVE_LOCK, and the ACTION_FINDINPUT, ACTION_FINDOUTPUT
and ACTION_FINDUPDATE packets (to open files) want a constant
ACCESS_READ or ACCESS_WRITE. To enter a constant, select it
from the "Constants" menu, then click on the appropriate
dp_Arg button.
FileHandle - A FileHandle field should point to a struct FileHandle. You
can allocate a struct FileHandle by clicking on the "Allocate
HANDLE" button in the main window, or by selecting the menu
item. Once a FileHandle window is active, you can enter it
into the appropriate dp_Arg field by clicking on the window,
then clicking on the dp_Arg button on the left of the main
window. You may also type the name of the window directly
by clicking into the argument data area and typing.
fh_Arg1 - Many packets require the fh_Arg1 field from an open FileHandle
to do their stuff. The ACTION_READ, ACTION_WRITE and
ACTION_END packets are examples. Click on the FileHandle
window, then on the dp_Arg button to set this up.
Data Buffer- Allocate a data buffer with the "Allocate BUFFER" button.
You can set up a dp_Arg field to use the buffer by clicking on
the data buffer window, then on the appropriate dp_Arg button.
If the packet also requires a size (as in ACTION_READ and
ACTION_WRITE), you can click on the data buffer window and
then the dp_Arg field for the integer and the length of the
buffer will be filled into the field for you. (If you want
to read or write less than the length of the buffer, just
type the value in to the field.)
FileInfoBlock- Allocate a FileInfoBlock with the "Allocate FILEINFO" button.
You can set up a dp_Arg field to use it by clicking on its
window, then on the appropriate dp_Arg button.
InfoData - Allocate an InfoData with the "Allocate INFODATA" button.
You can set up a dp_Arg field to use it by clicking on its
window, then on the appropriate dp_Arg button.
BOOLEAN - BOOLEAN values should be a constant DOSTRUE or DOSFALSE.
Select the appropriate constant from the "Constants" menu,
then click on the dp_Arg button for the field you want to
enter the constant.
------------------------------DANGER!! Will Robinson.. DANGER!!
When using PickPacket, you are messing around with some low-level DOS
functionality. Handlers expect valid values in their argument fields.
YOU CAN AND WILL CRASH YOUR MACHINE IF YOU SEND THE WRONG THING. For
example, one excellent way of crashing the system is to open a file
on device df0: and pass the FileHandle to RAM: with an ACTION_WRITE
packet. PickPacket checks some things, but in general, you need to be
careful to send reasonable values, just as you would if you were writing
a program to send the packets yourself. (Note, see disclaimer above!!!)
In particular, sending two ACTION_END packets for the same handle to the
Fast File System may cause you to have to revalidate the hard disk.
How many ways can you think of to trash your machine ?
Meditate on it for a while...